package com.wg.web_app;

import java.util.List;

public class StringUtil {
	// 首字母转小写
	public static String toLowerCaseFirstOne(String s) {
		if (Character.isLowerCase(s.charAt(0)))
			return s;
		else
			return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
	}

	// 首字母转大写
	public static String toUpperCaseFirstOne(String s) {
		if (Character.isUpperCase(s.charAt(0)))
			return s;
		else
			return (new StringBuilder()).append(Character.toUpperCase(s.charAt(0))).append(s.substring(1)).toString();
	}
	
	public static String getListString(List<? extends Object> list,String division){
		return getListString(list,division,"");
	}
	
	public static String getListString(List<? extends Object> list,String division,String surround){
		return getListString(list,division,surround,surround);
	}
	
	public static String getListString(List<? extends Object> list,String division,String surroundLeft,String surroundRight){
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<list.size();i++){
			sb.append(surroundLeft);
			sb.append(list.get(i));
			sb.append(surroundRight);
			if( i < list.size() - 1 )
				sb.append(division);
		}
		return sb.toString();
	}
	
	public static String getListOfStr(String str,int length,String division){
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<length;i++){
			sb.append(str);
			if( i < length - 1 )
				sb.append(division);
		}
		return sb.toString();
	}
}
